import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.Random;

/**
 * Created by shiyanqi on 19/4/9.
 */
public class Tools {

    public static String genOrderNumber(int id) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
        String d = sdf.format(new Date());
        d += String.format(Locale.CHINA, "%07d%s", id, genRandomString(6));
        return d;
    }

    private static String genRandomString(int length) {
        String base = "1234567890";
        Random random = new Random();
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < length; i++) {
            int number = random.nextInt(base.length());
            sb.append(base.charAt(number));
        }
        return sb.toString();
    }

}
